"""
    create by IAmFiveHigh on 2023/8/27
"""
from LA.LinearSystem import LinearSystem, inverse, rank
from LA.Matrix import Matrix
from LA.Vector import Vector


def calculate_linear_system(t: Matrix, v: Vector):
    l = LinearSystem(t, v)
    l.fancy_print()
    print("-" * 10, "高斯消元后", "-" * 10)
    l.gauss_jordan_elimination()
    l.fancy_print()

    print(f"矩阵的秩 == {rank(t)}")
    print("-" * 30)


if __name__ == '__main__':
    T = Matrix([[1, 2, 3],
                [1, 6, 8],
                [1, 10, 6]])
    v = Vector([0, 0, 0])
    calculate_linear_system(T, v)

    T2 = Matrix([[1, 2, 3],
                 [1, 6, 8],
                 [1, 10, 13]])
    calculate_linear_system(T2, v)

    T3 = Matrix([[1, 2, 3],
                 [1, 6, 7],
                 [1, 10, 6]])
    v3 = Vector([5, 9, 8])
    calculate_linear_system(T3, v3)

    T4 = Matrix([[1, 2, 3],
                 [1, 3, 4],
                 [1, 4, 5]])
    v4 = Vector([5, 6, 7])
    calculate_linear_system(T4, v4)

    T5 = Matrix([[1, 2],
                 [3, 4]])

    print(f"{T5}的逆矩阵 = {inverse(T5)}")
    print(f"{T5} · {inverse(T5)} = {T5.dot(inverse(T5))}")

